home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / mus / misc / NSM074.lha / nsm / plug-ins / readstr.a < prev    next >
Text File  |  1999-01-06  |  3KB  |  160 lines

  1.  
  2. ;    Functions to use a con-window in Octamed.
  3. ;    Con-windows are really fast, small, easy
  4. ;    and practical to use. No need to use gadgets.
  5. ;
  6. ;    (ok, most all of these functions except one
  7. ;    are accessable directly from c, but I just can't
  8. ;    get them to work.)
  9. ;
  10. ;    Made by Kjetil S. Matheussen, 3.1.99.
  11.  
  12.  
  13.             xdef    _opendoslibrary
  14.             xdef    _openfile
  15.             xdef    _openoctacon
  16.             xdef    _closefile
  17.             xdef    _readstring
  18.             xdef    _writestring
  19.             xdef    _closedoslibrary
  20.  
  21.             section    text,code
  22.  
  23.  
  24. _opendoslibrary:
  25.             move.l    a6,-(sp)
  26.             move.l    4.w,a6
  27.             lea.l        dosname,a1
  28.             jsr        -$198(a6)
  29.             move.l    a6,(sp)+
  30.             rts
  31.  
  32. ;    d1=filestring,d2=accessMode,a6=dosbase,
  33. _openfile:
  34.             jmp        -30(a6)
  35.  
  36.  
  37.  
  38. ;input:
  39. ;a5=dosbase
  40. ;d3=window-width
  41. ;d2=window-height
  42.  
  43. ;used registers:
  44. ;a3=constring
  45. _openoctacon:
  46.             movem.l    d2/d3/d7/a3/a6,-(sp)
  47.  
  48.             lea        constring(pc),a3
  49.  
  50.             lea.l        intuitionname,a1            ;open intuition.library
  51.             move.l    4.w,a6
  52.             jsr        -$198(a6)
  53.             move.l    d0,a6
  54.  
  55.             lea.l        octascreenname,a0            ;LockPubScreen
  56.             jsr        -$1fe(a6)
  57.             move.l    d0,a1
  58.  
  59.             move.w    8(a1),d7                        ;Find the left-edge
  60.             neg.w        d7
  61.             add.w        #50,d7                        ;*hark*
  62.             moveq        #4,d1
  63.             bsr.s        uwordtostring
  64.  
  65.             move.w    $a(a1),d7                    ;Find the top-edge
  66.             neg.w        d7
  67.             moveq        #10,d1
  68.             bsr.s        uwordtostring
  69.  
  70.             move.l    #0,a0                            ;UnlockPubScreen
  71.             jsr        -$204(a6)
  72.  
  73.             move.l    a6,a1
  74.             move.l    4.w,a6                        ;Close intution-library
  75.             jsr        -414(a6)
  76.  
  77.             move.l    d2,d7                            ;Set window-height
  78.             moveq        #22,d1
  79.             bsr.s        uwordtostring
  80.  
  81.             move.l    d3,d7                            ;Set window-width
  82.             moveq        #16,d1
  83.             bsr.s        uwordtostring
  84.  
  85.  
  86. ;    d1=filestring,d2=accessMode,a6=dosbase - Open file
  87.             move.l    a3,d1
  88.             move.l    #$3ee,d2
  89.             move.l    a5,a6
  90.             jsr        -30(a6)
  91.  
  92.             movem.l    (sp)+,d2/d3/d7/a3/a6
  93.             rts
  94.  
  95. uwordtostring:
  96.     move.l    a3,a0
  97.  
  98.     addq.w    #5,d1
  99.     add.l        d1,a0
  100.  
  101.     moveq        #3,d1                                        ;Accomumlate 4 digits first
  102. prevdigit:
  103.     andi.l    #$0000ffff,d7                            ;Clears the reminder
  104.     divu        #10,d7
  105.     move.l    d7,d0
  106.     swap        d0                                            ;D0 will now be the reminder of the d7/10 division
  107.     add.b        #$30,d0
  108.     move.b    d0,-(a0)                                    ;Sets the 4 last digits
  109.     dbra        d1,prevdigit
  110.  
  111.     add.b        #$30,d7
  112.     move.b    d7,-(a0)                                    ;Sets the first digit
  113.  
  114.     rts
  115.  
  116.  
  117. ;    d1=filehandle,a6=dosbase
  118. _closefile:
  119.             jmp        -36(a6)
  120.  
  121.  
  122. ;    d1=filehandle,d2=buffer,d3=length,a6=dosbase
  123. _readstring:
  124.             jsr        -42(a6)
  125.             move.l    d2,a0
  126.             move.b    #0,-1(a0,d0)
  127.             rts
  128.  
  129. ;d1=filehandle,d2=buffer,d3=length,a6=dosbase
  130. _writestring:
  131.             jmp        -48(a6)
  132.  
  133.  
  134. ;    a1=dosbase
  135. _closedoslibrary:
  136.             move.l    a6,-(sp)
  137.             move.l    4.w,a6
  138.             jsr        -414(a6)
  139.             move.l    (sp)+,a6
  140.             rts
  141.  
  142.  
  143.  
  144.  
  145. dosname:
  146.             dc.b        "dos.library",0
  147.  
  148. intuitionname:
  149.             dc.b        "intuition.library",0
  150.  
  151. constring:
  152.             dc.b        "CON:00000/00000/00000/00000/NSM plugin-window/SCREEN"
  153.  
  154. octascreenname:
  155.             dc.b        "OCTAMED",0
  156.  
  157.  
  158.             END
  159.  
  160.